/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DBA;
import baseDeDatos.ConexionMySQL;
import java.sql.*;
import javax.swing.JOptionPane;


/**
 *
 * @author Jorge
 */
public class DBA_Competencia {
    
    public int buscar (String  nombre){
     ConexionMySQL mysql = new ConexionMySQL();
        Connection conector = mysql.Conectar();
        String sSQL = "";
        
        sSQL="SELECT idCompetencia FROM competencia WHERE nombre = \""+nombre+"\"";
        int existe=0;
           try
        {
            Statement st = conector.createStatement();
            ResultSet rs = st.executeQuery(sSQL);
    

            while(rs.next())
            {
                 existe = rs.getInt("idCompetencia");
            }
 
           return existe;  

        } 
        catch (SQLException ex)
        {
            JOptionPane.showMessageDialog(null, ex);
             return 0;   
        }
        
    }
    
}
